package wsh;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.math.RoundingMode;
import java.net.ServerSocket;
import java.net.Socket;
import java.text.DecimalFormat;

/**
 * 文件传输Server端
 * 
 */
public class ServerReverse extends ServerSocket {

	private static final int SERVER_PORT = 8899;

	private static DecimalFormat df = null;

	static {

		df = new DecimalFormat("#0.0");
		df.setRoundingMode(RoundingMode.HALF_UP);
		df.setMinimumFractionDigits(1);
		df.setMaximumFractionDigits(1);
	}

	public ServerReverse() throws Exception {
		super(SERVER_PORT);
	}

	public void load() throws Exception {
		while (true) {
			Socket socket = this.accept();
			new Thread(new Task(socket)).start();
		}
	}

	class Task implements Runnable {

		private Socket socket;

		public Task(Socket socket) {
			this.socket = socket;
		}

		@Override
		public void run() {
	

				DataInputStream in1 = new DataInputStream(socket.getInputStream());
				DataOutputStream out1 = new DataOutputStream(socket.getOutputStream());
				
					int w = in1.readInt();
					Arrary.arrary[0] = w;
					System.out.println(Arrary.arrary[0]);
					out1.writeUTF("请等待");
				
				System.out.println("输入完毕！");
		
		
	}
	
		/**
		 * 入口
		 * 
		 * @param args
		 */
		public void main(String[] args) {
			try {
				ServerReverse server = new ServerReverse();
				server.load();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
